var cart;
function updateCart() {
    var quantity = document.getElementById("quantity").value;
    cart = new XMLHttpRequest();
    cart.onreadystatechange = fun;
    cart.open("GET","updateCart?quantity="+quantity,true);
    cart.send(null);
}

function fun() {
    if (cart.readyState ===4) {
        if (cart.status ===200) {
            var info = cart.responseText;
            console.log(info);
            var array = info.split(",");
            var quantity = document.getElementById("quantity");
            var total = document.getElementById("total");
            var subtotal = document.getElementById("subtotal");
            quantity.innerText = array[0];
            total.innerText = array[1];
            subtotal.innerText = array[2];
        }
    }
}